package com.jetpackmvp

import android.os.Bundle
import android.os.SystemClock
import android.util.Log
import com.jetpackmvp.base.TitleBarActivity
import com.jetpackmvp.module.UserContract
import com.jetpackmvp.module.UserPresenterImpl
import com.jetpackmvp.R
import com.jetpackmvp.utils.LogUtil
import com.jetpackmvp.widgets.ProcessDialog
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : TitleBarActivity(), UserContract.View {

    lateinit var alertDialog2: ProcessDialog

    private val presenter by lazy {
        UserPresenterImpl()
    }

//    override fun getLayoutContentId(): Int =

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        initView(savedInstanceState)
        alertDialog2 = ProcessDialog(this)

    }

    fun initView(savedInstanceState: Bundle?) {
        LogUtil.e("MainActivity")
        setTitleBarText("主页")
        presenter.attachView(this)
        button.setOnClickListener {
            alertDialog.showNormal()

//            LogUtil.d(presenter.getUser())
        }
    }

    override fun showUserSuccess() {
//        dismissProgressDialog()
        alertDialog.dismiss()
        LogUtil.d("success")
    }

    override fun showUserFailed() {
    }


    fun start() {
        val runnable = Runnable {
            SystemClock.sleep(20000)
        }
        Log.e("start", "start")
        Thread(runnable).start()
    }




}
